package com.scpii.api.util;

import org.springframework.security.core.context.SecurityContextHolder;

import com.scpii.api.domain.auth.UsersInfoDetails;

public class PrincipalUtil {

	/**
	 * 获取当前登录用户 包括匿名用户
	 * 
	 * @return
	 */
	public static UsersInfoDetails getPrincipal() {
		Object principal = SecurityContextHolder.getContext()
				.getAuthentication().getPrincipal();
		if (principal instanceof UsersInfoDetails) {
			return (UsersInfoDetails) principal;
		}
		return null;
	}

}
